import Mock from 'mockjs'
import { CONSTANT_OBJ } from '@/utils/constant'
let baseURL
let locationHref = `http://${window.location.hostname}`
if (CONSTANT_OBJ.ENV !== 'prodMaster') {
  baseURL = CONSTANT_OBJ.URL + CONSTANT_OBJ.PREFIX + '/user'
  // baseURL = URL
} else {
  baseURL = locationHref + CONSTANT_OBJ.PREFIX + '/user'
}
// 用户列表查询
Mock.mock(`${baseURL}/v1/api/user/role/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 4,
      list: [
        { roleName: '系统管理员', roleCode: '10001', roleNum: 1, roleStatus: 'OPEN', roleDesc: '暂无相关描述', updateTime: '2022-08-05-12:23:12', roleId: '1' },
        { roleName: '城市经理', roleCode: '10002', roleNum: 3, roleStatus: 'CLOSE', roleDesc: '暂无相关描述', updateTime: '2022-08-05-12:23:12', roleId: '2' },
        { roleName: '业务主任', roleCode: '10003', roleNum: 3, roleStatus: 'OPEN', roleDesc: '暂无相关描述', updateTime: '2022-08-05-12:23:12', roleId: '3' },
        { roleName: '客户经理', roleCode: '10004', roleNum: 3, roleStatus: 'CLOSE', roleDesc: '暂无相关描述', updateTime: '2022-08-05-12:23:12', roleId: '4' }
      ]
    }
  }
})

// 新增用户
Mock.mock(`${baseURL}/v1/api/user/role/add`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 更新用户
Mock.mock(`${baseURL}/v1/api/user/role/edit`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 查询职务详细信息
Mock.mock(`${baseURL}/v1/api/user/role/queryById/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      roleId: 1,
      roleName: '系统管理员',
      roleCode: '10001',
      revision: 2333,
      roleStatus: 'CLOSE',
      userList: [
        { realName: '快乐星球', userId: '78956', organizationName: '审批不', createTime: '2022-06-12' }
      ]
    }
  }
})

// 职务关联用户
Mock.mock(`${baseURL}/v1/api/user/role/relate/user`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { realName: '快乐星球', userId: '78956' },
      { realName: '快乐朋友', userId: '78946' }
    ]
  }
})

// 更新用户
Mock.mock(`${baseURL}/v1/api/user/role/change/dataPermissions`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})
// 关闭角色
Mock.mock(`${baseURL}/v1/api/user/role/close`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 启动角色
Mock.mock(`${baseURL}/v1/api/user/role/open`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 删除角色
Mock.mock(`${baseURL}/v1/api/user/role/delete/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})
